import fetch from "@/utils/http";

/** 登录 */
export interface LoginParams {
  username: string;
  password: string;
  sessionId: string;
  sig: string;
  token: string;
  smsCode: string;
}
export const getLogin = (data?: LoginParams) => {
  return fetch<string>("/operator/login", "MOCK", {
    method: "post",
    body: JSON.stringify(data)
  });
};

/**
 * 用户信息
 */
export interface Info {
  operatorUuid: string;
  companyUuid: string;
  loginName: string;
  accountNonLocked: boolean;
  realName: string;
  mobile: string;
  email: string;
  type: number;
  loginTimes: number;
  remark: string;
  companyName: string;
  isCompanyAdmin: boolean;
  backgroundColor: any;
  position: string;
  companyShortName: string;
  roleKeyList: string[];
  jobUuid: any;
  isOnline: any;
}
export const getInfo = () => {
  return fetch<Info>("/operator/info", "MOCK", {
    method: "get"
  });
};

/**
 * 图形验证码
 */
interface CodeResponse {
  imageCode: string;
  key: string;
}
export const getValidateCode = () => {
  return fetch<CodeResponse>("/auth/validate_code", "MANGMENT", {
    method: "get"
  });
};

/**
 * 登录 发送验证码
 */
interface SmsCodeParams {
  imageCode: string;
  key: string;
  mobile: string;
}
export const sendSmsCode = (data: SmsCodeParams) => {
  return fetch("/auth/sms/login/send", "MANGMENT", {
    method: "post",
    body: JSON.stringify(data)
  });
};
/**
 * 重置密码 发送验证码
 */
export const sendPasswordCode = (data: SmsCodeParams) => {
  return fetch("/auth/sms/password/send", "MANGMENT", {
    method: "post",
    body: JSON.stringify(data)
  });
};
